<?php

namespace App\Listeners;

use App\Events\EventConsignmentNote;
use App\Jobs\ConsignmentNoteQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use PHPUnit\Runner\Exception;
use Symfony\Component\Translation\Exception\NotFoundResourceException;

class EventListenerConsignmentNote
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {

    }

    /**
     * Handle the event.
     *
     * @param  EventConsignmentNote  $event
     * @return void
     */
    public function handle(EventConsignmentNote $event)
    {
        try{
            $order=$event->ReturnData;
            ConsignmentNoteQueue::dispatch($order)->onQueue('ConsignmentNoteQueue');
        }catch (\Exception $exception){
            throw new NotFoundResourceException($exception->getMessage());
        }
    }
}
